package com.avic.modules.statistics.service.impl;

import com.avic.common.service.impl.BaseServiceImpl;
import com.avic.common.utils.QueryHelpPlus;
import com.avic.modules.equipment.service.EquipmentService;
import com.avic.modules.statistics.domain.KanbanStatistics;
import com.avic.modules.statistics.service.KanbanStatisticsService;
import com.avic.modules.statistics.service.dto.KanbanStatisticsQueryCriteria;
import com.avic.modules.statistics.service.mapper.KanbanStatisticsMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zhangzikang
 * @date 2022-08-14
 */
@Service(value = "kanbanStatisticsService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class KanbanStatisticsServiceImpl extends BaseServiceImpl
        <KanbanStatisticsMapper, KanbanStatistics> implements KanbanStatisticsService {

    private final KanbanStatisticsMapper kanbanStatisticsMapper;


    public KanbanStatisticsServiceImpl(KanbanStatisticsMapper kanbanStatisticsMapper) {
        this.kanbanStatisticsMapper = kanbanStatisticsMapper;

    }

    @Override
    public KanbanStatistics queryKanbanStatistics(String equipId) {
        KanbanStatisticsQueryCriteria criteria = new KanbanStatisticsQueryCriteria();
        criteria.setEquipId(equipId);
        return baseMapper.selectOne(QueryHelpPlus.getPredicate(KanbanStatistics.class,criteria));
    }

    @Override
    public void addKanbanStatistics(KanbanStatistics kanbanStatistics) {

        kanbanStatisticsMapper.insert(kanbanStatistics);
    }

    @Override
    public void eatKanbanStatistics(KanbanStatistics kanbanStatistics) {
        kanbanStatisticsMapper.updateById(kanbanStatistics);
    }

    @Override
    public void del(KanbanStatistics kanbanStatistics) {
        kanbanStatisticsMapper.deleteById(kanbanStatistics);
    }
}
